unit referenceAnotherForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, NumEdit, PBCheckLB, Buttons;

type
  TreferenceScreen = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    instancMethodEdit: TEdit;
    imStringEdit: TEdit;
    Button1: TButton;
    workNodesCombo: TComboBox;
    Button2: TButton;
    Label4: TLabel;
    passNameEdit: TEdit;
    Label5: TLabel;
    iterationsEdit: TIntEdit;
    BitBtn1: TBitBtn;
    procedure workNodesComboChange(Sender: TObject);

    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
    workNodeIndex : Integer;
    dataType : Integer;
    tmpList : TPBCheckListBox;
  public
    { Public declarations }
    procedure myShow(dType : Integer);
  end;

var
  referenceScreen: TreferenceScreen;

implementation

uses globals, workNode, mainScreen, PassLookUpForm;

{$R *.dfm}

procedure TreferenceScreen.workNodesComboChange(Sender: TObject);
begin
        imStringEdit.Text := workNodesCombo.Items.Strings[workNodesCombo.ItemIndex];
end;

procedure TreferenceScreen.myShow(dType : Integer);
var
  i : Integer;
begin
workNodesCombo.Items.Clear;
dataType := dType;
case dataType of
  WORK_NODE_TYPE:
                 begin
                   tmpList := globalView.wnList;
                   iterationsEdit.Visible := true;
                   passNameEdit.Visible := true;
                   BitBtn1.Visible := true;
                   label4.Visible := true;
                   label5.Visible := true;
                 end;
  RESOURCE_TYPE:
                 begin
                   tmpList := globalView.resList;
                   iterationsEdit.Visible := false;
                   passNameEdit.Visible := false;
                   BitBtn1.Visible := false;
                   label4.Visible := false;
                   label5.Visible := false;
                 end;
  PASS_TYPE:
                 begin
                 end;
end;
workNodeIndex := tmpList.ItemIndex;
Caption := 'Reference Screen For working Node: '+tmpList.Items.Strings[workNodeIndex];
for i:=0 to tmpList.Items.Count-1 do
  begin
    if(i <> tmpList.ItemIndex) then
      workNodesCombo.Items.Add( tmpList.Items.Strings[i] );
  end;
showModal;
end;

procedure TreferenceScreen.Button1Click(Sender: TObject);
begin
case dataType of
WORK_NODE_TYPE:
               begin
                 baseClassData(WN_DataList.Items[workNodeIndex]).set_instancingMethod(instancMethodEdit.Text);
                 baseClassData(WN_DataList.Items[workNodeIndex]).set_imStringData(imStringEdit.Text);
                 baseClassData(WN_DataList.Items[workNodeIndex]).set_passName(passNameEdit.Text);
                 baseClassData(WN_DataList.Items[workNodeIndex]).set_iterations(StrToInt(iterationsEdit.Text));
                 globalView.wnListClick(nil);
               end;

RESOURCE_TYPE :
               begin
                 baseClassData(Resources_DataList.Items[workNodeIndex]).set_instancingMethod(instancMethodEdit.Text);
                 baseClassData(Resources_DataList.Items[workNodeIndex]).set_imStringData(imStringEdit.Text);
                 baseClassData(Resources_DataList.Items[workNodeIndex]).set_passName(passNameEdit.Text);
                 baseClassData(Resources_DataList.Items[workNodeIndex]).set_iterations(StrToInt(iterationsEdit.Text));
                 globalView.resListClick(nil);
               end;
PASS_TYPE     : ;
end;
close();
end;

procedure TreferenceScreen.Button2Click(Sender: TObject);
begin
close;
end;

procedure TreferenceScreen.BitBtn1Click(Sender: TObject);
var
 tmp : String;
begin
passLookUpScreen.showModal;
if passLookUpScreen.get_SelectedPassName(tmp) = true then
  passNameEdit.Text := tmp;
end;

end.
